//
//  HMVisitorViewController.swift
//  WeiboPre12
//
//  Created by EnjoySR on 15/12/25.
//  Copyright © 2015年 EnjoySR. All rights reserved.
//

import UIKit

class TFVisitorTableViewController: UITableViewController, TFVisitorViewDelegate {
    
    /// 用户登录标记
    var userLogon = TFUserAccountViewModel.sharedViewModel.userLogin
    
    override func loadView() {
        userLogon ? super.loadView() : setupVisitorView()
    }
    
    /// 设置访客视图
    private func setupVisitorView() {
        view = visitorView
        
        // 添加导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "visitorLoginViewWillLogin")
    }
    
    // MARK: - VisitorLoginViewDelegate
    func visitorLoginViewWillLogin() {
        print("登录")
        presentViewController(UINavigationController(rootViewController: TFOAuthViewController()), animated: true, completion: nil)
    }
    
    func visitorLoginViewWillRegister() {
        print("注册")
        presentViewController(UINavigationController(rootViewController: TFOAuthViewController()), animated: true, completion: nil)
    }
    
    // MARK: - 懒加载控件
    
    lazy var visitorView: TFVisitorView = {
        let visitorView = TFVisitorView()
        visitorView.delegate = self
        return visitorView
    }()
    
    
}
